package com.dc.bobaoge.project.v2.to.v3.business.core;

import com.dc.bobaoge.project.base.core.old.mapper.OldCoreFictitiousMapper;
import com.dc.bobaoge.project.v2.to.v3.business.core.util.FictitiousUtil;
import com.own.business.sync.trigger.base.entity.SyncTrigger;
import com.own.business.sync.trigger.base.method.ResolveMethod;
import com.own.component.common.exception.BusinessSimpleException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * FictitiousResolveMethod
 *
 * @author chenxueli
 * @date 2024-01-17 13:34:00
 */
@Slf4j
@Component
public class FictitiousResolveMethod implements ResolveMethod {

    @Resource
    private OldCoreFictitiousMapper oldCoreFictitiousMapper;

    @Resource
    private FictitiousUtil fictitiousUtil;

    /**
     * 修改的处理方法
     *
     * @param trigger 日志信息
     */
    @Override
    public void update(SyncTrigger trigger) {
        var oldCoreFictitious = oldCoreFictitiousMapper.selectById(trigger.getTargetId());
        if (oldCoreFictitious == null) {
            throw new BusinessSimpleException("未查询到虚拟钱包的信息");
        }
        fictitiousUtil.init(oldCoreFictitious.getBcXuniUserId());
    }

    /**
     * 名称信息
     *
     * @return 名称
     */
    @Override
    public String name() {
        return "fictitious";
    }

}
